package com.hc.race.controller;

import com.hc.race.dto.Result;
import com.hc.race.entity.Progress;
import com.hc.race.service.ProgressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author zy
 * @Date 2023/11/25 12:01
 * @PackageName:com.hc.race.controller
 * @ClassName: ProgressController
 * @Description: TODO
 * @Version 1.0
 */
@RestController
@RequestMapping("progress")
public class ProgressController {
    @Autowired
    private ProgressService progressService;

    @GetMapping("/dayInfo")
    public Result<Progress> getDayInfo(@RequestParam Long userId, @RequestParam Long taskId) {
        Progress progress = progressService.getDayInfo(userId, taskId);
        if (progress != null) {
            return Result.success(progress);
        } else {
            return Result.error("没有数据");
        }
    }

    @PostMapping("/success")
    public Result success(@RequestBody Progress progress) {
        progressService.success(progress);
        return Result.success("success");
    }

    @PostMapping("/sendEmailToFriend")
    public Result sendEmailToFriend(@RequestParam Long userId, @RequestParam Long friendId, @RequestParam Long taskId) {
        progressService.sendEmailToFriend(userId, friendId, taskId);
        return Result.success("success");
    }
}
